package com.linwen.excise.od.C;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @ClassName _CPU算力分配
 * @Description TODO
 * @Author zero
 * @DATE 2024/4/14 6:35 PM
 * @Version 1.0
 */
public class _CPU算力分配 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] arr1 = new int[n];
        int[] arr2 = new int[m];
        for (int i = 0; i < n; i++) {
            arr1[i] = scanner.nextInt();
        }
        for (int i = 0; i < m; i++) {
            arr2[i] = scanner.nextInt();
        }
        int[] result = function(arr1,arr2);
        System.out.println(result[0]+" "+result[1]);


    }

    private static int[] function(int[] arr1, int[] arr2) {
        int[] result = new int[2];
        Arrays.sort(arr1);
        int sum1 = 0;
        for (int i = 0; i < arr1.length; i++) {
            sum1 += arr1[i];
        }
        int sum2 = 0;
        for (int i = 0; i < arr2.length; i++) {
            sum2 += arr2[i];
        }
        int k = (sum1- sum2)/2;
        if (k == 0) {
            result[0] = arr1[0] = 0;
        }
        for (int i : arr1) {
            for (int j : arr2) {
                if(i-j==k){
                    result[0] = i;
                    result[1] = j;
                    return result;
                }
            }
        }
        return result;
    }
}
